package org.gruposp2p.openid.util;

import java.util.Random;

public class RandomPasswordGenerator {

	private static final char[] RANDOM_CHARS = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" 
			+ "abcdefghijklmnopqrstuvwxyz"
			+ "0123456789").toCharArray();

	public String generate(final int length) {
		StringBuffer result = new StringBuffer(length);
		Random random = new Random(); 
		for (int i = 0; i < length; i++) {
			result.append(RANDOM_CHARS[random.nextInt(RANDOM_CHARS.length)]);
		}
		return result.toString();
	}
}
